@section('title')
	找律师 @parent
@show
@section('content')
	<div style="width:600px; margin:auto">
		<form method="post" id="js-form" action="">
		<table align="center" border="1">
			<tr>
				<th width="100">选择</th>
				<th width="100">id</th>
				<th width="100">名字</th>
			</tr>
			@foreach($data['groups'] as $group)
			<tr align="center">
				<td>
					<input type="checkbox" name="groupId[]" value="{{ $group['id'] }}">
				</td>
				<td>{{ $group['id'] }}</td>
				<td>{{ $group['group_name'] }}</td>		
			</tr>
			@endforeach
			</th>
		</table>
		
		<div>
		<br>
			<input type="hidden" name="_token" value="{{ csrf_token() }}" />&nbsp;&nbsp;
			<input type="button" onclick="ck(true)" value="全选">&nbsp;&nbsp;<input type="button" onclick="ck(false)" value="取消全选">&nbsp;&nbsp;
			<a href="javascript:void(0)" id="register">注册环信</a> 
		</div>
		</form>
		<div>
		<br>
		<a href="{{ route('easemob.groups') }}">查看已注册环信的圈子</a>&nbsp;&nbsp;
		<a href="{{ route('easemob.noeasemobgroups') }}">查看未注册环信的圈子</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		</div>
	</div>
	<SCRIPT LANGUAGE="JavaScript">
function ck(b)
{
    var input = document.getElementsByTagName("input");

    for (var i=0;i<input.length ;i++ )
    {
        if(input[i].type=="checkbox")
            input[i].checked = b;
    }

    
}
$(document).on( "click",  "#register", function(e){
	var url = "{{ route('easemob.register.group') }}";
	var form = $('#js-form');
	$.post(url, form.serialize(), function(data){
	    }, 'json').error(function(data){
	    	var obj = $.parseJSON(data.responseText);
		    }).success(function(data){
				layer.msg('注册成功');
				location.reload();
	 });
})
</SCRIPT>
@show

